<div class="content-section introduction">
    <div class="feature-intro">
        <h1>RadioButton</h1>
        <p>RadioButton is an extension to standard radio button element with theming.</p>
    </div>
    <app-inputStyleSwitch></app-inputStyleSwitch>
</div>

<div class="content-section implementation">
    <div class="card">
        <h5>Basic</h5>
        <div class="p-field-radiobutton">
            <p-radioButton name="city" value="Chicago" [(ngModel)]="city" inputId="city1"></p-radioButton>
            <label for="city1">Chicago</label>
        </div>
        <div class="p-field-radiobutton">
            <p-radioButton name="city" value="Los Angeles" [(ngModel)]="city" inputId="city2"></p-radioButton>
            <label for="city2">Los Angeles</label>
        </div>
        <div class="p-field-radiobutton">
            <p-radioButton name="city" value="New York" [(ngModel)]="city" inputId="city3"></p-radioButton>
            <label for="city3">New York</label>
        </div>
        <div class="p-field-radiobutton">
            <p-radioButton name="city" value="San Francisco" [(ngModel)]="city" inputId="city4"></p-radioButton>
            <label for="city4">San Francisco</label>
        </div>

        <h5>Dynamic Values, Preselection, Value Binding and Disabled Option</h5>
        <div *ngFor="let category of categories" class="p-field-checkbox">
            <p-radioButton inpudIt="category.key" name="category" [value]="category" [(ngModel)]="selectedCategory" [disabled]="category.key === 'R'"></p-radioButton>
            <label [for]="category.key">{{category.name}}</label>
        </div>
    </div>
</div>

<div class="content-section documentation">
    <p-tabView>
        <p-tabPanel header="Documentation">
            <h5>Import</h5>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
import &#123;RadioButtonModule&#125; from 'primeng/radiobutton';
</app-code>

            <h5>Getting Started</h5>
            <p>Two-way value binding is defined using the standard <i>ngModel</i> directive.</p>
            
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-radioButton name="groupname" value="val1" [(ngModel)]="selectedValue"&gt;&lt;/p-radioButton&gt;
&lt;p-radioButton name="groupname" value="val2" [(ngModel)]="selectedValue"&gt;&lt;/p-radioButton&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class ModelComponent &#123;

    selectedValue: string;

&#125;
</app-code>

            <p>As model is two-way binding enabled, giving a default value to the model is enough to display a radio button as checked by default.</p>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class ModelComponent &#123;

    selectedValue: string = 'val1';

&#125;
</app-code>

            <h5>Model Driven Forms</h5>
            <p>RadioButton can be used in a model driven form as well.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-radioButton name="groupname" value="ps4" formControlName="console"&gt;&lt;/p-radioButton&gt;
</app-code>

            <h4>Label</h4>
            <p>The <i>label</i> attribute provides a label text for the radio button. This label is also clickable and selects value.</p>
            <app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-radioButton name="groupname" value="val1" label="Option 2" [(ngModel)]="selectedValue"&gt;&lt;/p-radioButton&gt;
</app-code>

            <h5>Properties</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>name</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Name of the radiobutton group.</td>
                        </tr>
                        <tr>
                            <td>value</td>
                            <td>any</td>
                            <td>null</td>
                            <td>Value of the radiobutton.</td>
                        </tr>
                        <tr>
                            <td>label</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Label of the radiobutton.</td>
                        </tr>
                        <tr>
                            <td>disabled</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>When present, it specifies that the element should be disabled.</td>
                        </tr>
                        <tr>
                            <td>tabindex</td>
                            <td>number</td>
                            <td>null</td>
                            <td>Index of the element in tabbing order.</td>
                        </tr>
                        <tr>
                            <td>inputId</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Identifier of the focus input to match a label defined for the component.</td>
                        </tr>
                        <tr>
                            <td>ariaLabelledBy</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Establishes relationships between the component and label(s) where its value should be one or more element IDs.</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>object</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                        <tr>
                            <td>labelStyleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the label.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Events</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>onClick</td>
                            <td>event: Click event</td>
                            <td>Callback to invoke on radio button click.</td>
                        </tr>
                        <tr>
                            <td>onFocus</td>
                            <td>event: Focus event</td>
                            <td>Callback to invoke when the radio button receives focus.</td>
                        </tr>
                        <tr>
                            <td>onBlur</td>
                            <td>event: Blur event</td>
                            <td>Callback to invoke when the radio button loses focus.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Methods</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>focus</td>
                            <td>-</td>
                            <td>Applies focus.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Styling</h5>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Element</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>p-radiobutton</td>
                            <td>Container element</td>
                        </tr>
                        <tr>
                            <td>p-radiobutton-box</td>
                            <td>Container of icon.</td>
                        </tr>
                        <tr>
                            <td>p-radiobutton-icon</td>
                            <td>Icon element.</td>
                        </tr>
                        <tr>
                            <td>p-chkbox-label</td>
                            <td>Label element.</td>
                        </tr>
                        <tr>
                            <td>p-label-active</td>
                            <td>Label element of a checked state.</td>
                        </tr>
                        <tr>
                            <td>p-label-focus</td>
                            <td>Label element of a focused state.</td>
                        </tr>
                        <tr>
                            <td>p-label-disabled</td>
                            <td>Label element of a disabled state.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Dependencies</h5>
            <p>None.</p>
            
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/radiobutton" class="btn-viewsource" target="_blank">
                <span>View on GitHub</span>
            </a>
            <a href="https://stackblitz.com/edit/primeng-radiobutton-demo" class="btn-viewsource" style="margin-left: .5em;" target="_blank">
                <span>Edit in StackBlitz</span>
            </a>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;h5&gt;Basic&lt;/h5&gt;
&lt;div class="p-field-radiobutton"&gt;
    &lt;p-radioButton name="city" value="Chicago" [(ngModel)]="city" inputId="city1"&gt;&lt;/p-radioButton&gt;
    &lt;label for="city1"&gt;Chicago&lt;/label&gt;
&lt;/div&gt;
&lt;div class="p-field-radiobutton"&gt;
    &lt;p-radioButton name="city" value="Los Angeles" [(ngModel)]="city" inputId="city2"&gt;&lt;/p-radioButton&gt;
    &lt;label for="city2"&gt;Los Angeles&lt;/label&gt;
&lt;/div&gt;
&lt;div class="p-field-radiobutton"&gt;
    &lt;p-radioButton name="city" value="New York" [(ngModel)]="city" inputId="city3"&gt;&lt;/p-radioButton&gt;
    &lt;label for="city3"&gt;New York&lt;/label&gt;
&lt;/div&gt;
&lt;div class="p-field-radiobutton"&gt;
    &lt;p-radioButton name="city" value="San Francisco" [(ngModel)]="city" inputId="city4"&gt;&lt;/p-radioButton&gt;
    &lt;label for="city4"&gt;San Francisco&lt;/label&gt;
&lt;/div&gt;

&lt;h5&gt;Dynamic Values, Preselection, Value Binding and Disabled Option&lt;/h5&gt;
&lt;div *ngFor="let category of categories" class="p-field-checkbox"&gt;
    &lt;p-radioButton inpudIt="category.key" name="category" [value]="category" [(ngModel)]="selectedCategory" [disabled]="category.key === 'R'"&gt;&lt;/p-radioButton&gt;
    &lt;label [for]="category.key"&gt;&#123;&#123;category.name&#125;&#125;&lt;/label&gt;
&lt;/div&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class RadioButtonDemo &#123;
    city: string;

    selectedCategory: any = null;

    categories: any[] = [&#123;name: 'Accounting', key: 'A'&#125;, &#123;name: 'Marketing', key: 'M'&#125;, &#123;name: 'Production', key: 'P'&#125;, &#123;name: 'Research', key: 'R'&#125;];

    ngOnInit() &#123;
        this.selectedCategory = this.categories[1];
    &#125;
&#125;
</app-code>
        </p-tabPanel>
        <p-tabPanel header="StackBlitz">
            <ng-template pTemplate="content">
                <iframe src="https://stackblitz.com/edit/primeng-radiobutton-demo?embed=1" style="width: 100%; height: 768px; border: none;"></iframe>
            </ng-template>
        </p-tabPanel>
    </p-tabView>
</div>